The Loader Header
The loader header data structure is of fixed size (56 bytes) and has the form shown in Listing 8-3.Listing 8-3 Loader header data structure
struct PEFLoaderInfoHeader { SInt32mainSection; UInt32mainOffset; SInt32initSection; UInt32initOffset; SInt32termSection; UInt32termOffset; UInt32importedLibraryCount; UInt32totalImportedSymbolCount; UInt32relocSectionCount; UInt32relocInstrOffset; UInt32loaderStringsOffset; UInt32exportHashOffset; UInt32exportHashTablePower; UInt32exportedSymbolCount; };The fields in the loader header are as follows:
- The
mainSection
field (4 bytes) specifies the number of the section in this container that contains the main symbol. If the fragment does not have a main symbol, this field is set to-1
.- The
mainOffset
field (4 bytes) indicates the offset (in bytes) from the beginning of the section to the main symbol.- The
initSection
field (4 bytes) contains the number of the section containing the initialization function's transition vector. If no initialization function exists, this field is set to-1
.- The
initOffset
field (4 bytes) indicates the offset (in bytes) from the beginning of the section to the initialization function's transition vector.- The
termSection
field (4 bytes) contains the number of the section containing the termination routine's transition vector. If no termination routine exists, this field is set to-1
.- The
termOffset
field (4 bytes) indicates the offset (in bytes) from the beginning of the section to the termination routine's transition vector.- The
importedLibraryCount
field (4 bytes) indicates the number of imported libraries.- The
totalImportedSymbolCount
field (4 bytes) indicates the total number of imported symbols.- The
relocSectionCount
field (4 bytes) indicates the number of sections containing load-time relocations.- The
relocInstrOffset
field (4 bytes) indicates the offset (in bytes) from the beginning of the loader section to the start of the relocations area.- The
loaderStringsOffset
field (4 bytes) indicates the offset (in bytes) from the beginning of the loader section to the start of the loader string table.- The
exportHashOffset
field (4 bytes) indicates the offset (in bytes) from the beginning of the loader section to the start of the export hash table. The hash table should be 4-byte aligned with padding added if necessary.- The
exportHashTablePower
field (4 bytes) indicates the number of hash index values (that is, the number of entries in the hash table). The number of entries is specified as a power of two. For example, a value of0
indicates one entry, while a value of2
indicates four entries.If no exports exist, the hash table still contains one entry, and the value of this field is
0
.- The
exportedSymbolCount
field (4 bytes) indicates the number of symbols exported from this container.